package com.aaa.controller.api;

import com.aaa.aop.annotation.Log;
import com.aaa.entity.LoginInfo;
import com.aaa.service.LoginInfoService;
import com.aaa.vo.LoginInfoVo;
import com.aaa.vo.Result;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * @BelongsPackage: com.aaa.controller.api
 * @Description:
 * @CreateTime: 2023-03-31  09:14
 * @Author: ql
 */
@RestController
@RequestMapping("system/api/loginLog")
public class ApiLoginInfoController {

    @Autowired
    private LoginInfoService loginInfoService;

    @PostMapping("/queryByPage")
    public Result<IPage<LoginInfo>> queryByPage(@RequestBody Map<String,Object> map){
        //练习map传参
        LoginInfoVo a1 = JSON.parseObject(JSON.toJSONString(map.get("a1")), LoginInfoVo.class);
        System.out.println("------------------ = " + a1);
        return loginInfoService.queryByPage(a1);
    }

    @DeleteMapping("/deleteByIds/{id}")
    @Log(title = "批量删除",business_type = "1")
    public Result<String> deleteLogByIds(@PathVariable Long[] id){
        System.out.println("=========== " + Arrays.toString(id));
        return loginInfoService.deleteLogByIds(id);
    }
    @DeleteMapping("/delAll")
    @Log(title = "删除所有",business_type = "1")
    public Result<String> delAll(){
        return loginInfoService.delAll();

    }


}
